package es

import (
	"context"
	"strings"
)

// 获取索引模板
func (e *EsClient) IndexGetTemplate(name string) (res interface{}, err error) {
	return e.rawClient.IndexGetTemplate(strings.Split(name, ",")...).Do(context.TODO())
}

// 索引文件是否存在
func (e *EsClient) IndexTemplateExists(name string) (res interface{}, err error) {
	return e.rawClient.IndexTemplateExists(name).Do(context.TODO())
}

// 创建索引模板
func (e *EsClient) IndexPutTemplate(name, body string) (res interface{}, err error) {
	return e.rawClient.IndexPutTemplate(name).BodyString(body).Do(context.TODO())
}

// 删除索引模板
func (e *EsClient) IndexDeleteTemplate(name string) (res interface{}, err error) {
	return e.rawClient.IndexDeleteTemplate(name).Do(context.TODO())
}

// 使用索引模板创建索引
func (e *EsClient) IndexPutIndexTemplate(name, body string) (res interface{}, err error) {
	return e.rawClient.IndexPutIndexTemplate(name).BodyString(body).Do(context.TODO())
}

// 获取索引的索引模板
func (e *EsClient) IndexGetIndexTemplate(name string) (res interface{}, err error) {
	return e.rawClient.IndexGetIndexTemplate(name).Do(context.TODO())
}

// 删除索引的索引模板
func (e *EsClient) IndexDeleteIndexTemplate(name string) (res interface{}, err error) {
	return e.rawClient.IndexDeleteIndexTemplate(name).Do(context.TODO())
}